;;;; Created on 2011-04-27 14:30:30

;4.16
(defun my-number-func (a)
  (cond ((and (oddp a) (> a 0)) (* a a))
        ((and (oddp a) (< a 0)) (* a 2))
        (T (/ a 2))
  )
)

;4.17
(defun  my-gender(a b)
  (or (and (or (equal a 'boy) (equal a 'girl)) (equal b 'child))
      (and (or (equal a 'man) (equal a ' woman)) (equal b 'adult))
  )
)

;4.18
(defun play-win (a b)
  (or (and (equal a 'ROCK) (equal b 'Scissors))
          (and (equal a 'Scissors) (equal b 'Paper))
          (and (equal a 'paper) (equal b 'rock)))
  )

(defun play (a b)
  (cond ((play-win a b) 'FIRST-WINS)
        ((play-win b a) 'SECOND-WINS)
        (T 'TIE)
    )
  )

;4.19
(defun my-and (x y z w)
  (cond ((not x) nil)
        ((not y) nil)
        ((not z) nil)
        ((not w) nil)
        (T w)
    )
  )

;4.20
(defun compare (a b)
  (if (> a b) 'gt
      (if (< a b) 'lt 'eq))
  )

(defun my-and2 (a b)
  (if a b nil)
  )

(defun my-or (a b)
  (if a T b)
  )

;4.21
(defun gtest (lst)
  (if (equal (length lst) 1)
      (first lst)
      (if (equal (length lst) 2)
          (if (> (first lst) (second lst)) (first lst) (second lst))
	  (gtest (list (first lst) (gtest (rest lst))))
          )
      )
  )